#include "fig_ui_yesno.h"
#include "gen_game_state.h"
#include "fig_sounds.h"

#include "gameflow/ui_popup.h"

FIGUIYesNo::FIGUIYesNo(gameflow::UIPopup* pPopup)  : 
							FIGUIPopupAnimator(pPopup)
{
	
	
	if(m_pPopup)
	{
		SetCloseButton("NoWidget");
		m_pPopup->SetWidgetFunctor("NoWidget", UI_DELEGATE(FIGUIYesNo, OnButtonClose));
		AddToNaviationUI(m_pPopup->GetWidget("NoWidget"));
		AddToNaviationUI(m_pPopup->GetWidget("YesWidget"));
		FIGUIPopupAnimatorMgr::Instance().AddPopupAnimator(FIGUIPopupAnimatorMgr::POPUP_NAMES_YESNO,this);
		

	}
	m_Type = ANIMATION_MSGPOPUP;

}

void		FIGUIYesNo::Hide()
{
	if(GENGameState::GetGame())
		GENGameState::GetGame()->UnPause();
	audio::BassAudio::Instance().RestartAll();

	FIGUIPopupAnimator::Hide();
}


bool	FIGUIYesNo::OnUIKeyDownEvent(int	KeyCode)
{
	int NewKeyCode = KeyCode;
	
	if(KeyCode == input::MOGAJoystick::KEYCODE_DPAD_LEFT)
		NewKeyCode = input::MOGAJoystick::KEYCODE_DPAD_UP;

	else if(KeyCode == input::MOGAJoystick::KEYCODE_DPAD_RIGHT)
		NewKeyCode = input::MOGAJoystick::KEYCODE_DPAD_DOWN;
	
	return FIGUIPopupAnimator::OnUIKeyDownEvent(NewKeyCode);

}

void DELEGATE_CALL		FIGUIYesNo::OnButtonClose(ui::UIWidget::WIDGET_EVENT Event, ui::UIWidget* pWidget)
{
	this->Hide();
}
	